// pages/main/index.js
var QR = require("../../utils/qrcode.js");
Page({
  data:{
    canvasHidden:false,
    maskHidden:true,
    imagePath:'',
  
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    var size = this.setCanvasSize();//动态设置画布大小
    var initUrl = this.data.placeholder;
    //this.createQrCode(initUrl, "mycanvas", size.w, size.h);
  },
  onReady:function(){
  
  },
  onShow:function(){
    
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },

  onUnload:function(){
    // 页面关闭

  },
  //适配不同屏幕大小的canvas
  setCanvasSize:function(){
    var size={};
    try {
        var res = wx.getSystemInfoSync();
        var scale = 750/686;//不同屏幕下canvas的适配比例；设计稿是750宽
        var width = res.windowWidth/scale;
        var height = width;//canvas画布为正方形
        size.w = width;
        size.h = height;
      } catch (e) {
        // Do something when catch error
        console.log("获取设备信息失败"+e);
      } 
    return size;
  } ,
  formSubmit: function(e) {
    wx.navigateTo({
      url: '../generateQR/generateQR'
    })
  },
  formSaoSao: function (e) {
    wx.navigateTo({
      url: '../saosao/saosao'
    })
  },
  formShiMing: function (e) {
    wx.navigateTo({
      url: '../shiming/shiming'
    })
  },
})